<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员登录界面</title>
    <link rel="icon" href="/image/favicon.ico" type="image/x-icon"/>
    <style>
        body {
            background-image: url('/image/simpledesktops.png');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            background-attachment: fixed;
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .login-box {
            opacity: 0.75;
            width: 340px;
            padding: 20px;
            background-color: rgba(255, 255, 255, 0.8);
            border: 1px solid #ccc;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            border-radius: 5px;
            position: relative;
        }

        .login-box h2 {
            text-align: center;
            margin-bottom: 20px;
        }

        .input-group {
            margin-bottom: 15px;
            display: flex;
            flex-direction: column;
        }

        .input-group label {
            margin-bottom: 5px;
        }

        .input-group input[type="text"],
        .input-group input[type="password"] {
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        .input-group button[type="submit"] {
            padding: 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            margin-top: 10px;
        }

        .input-group button[type="submit"]:hover {
            background-color: #0056b3;
        }

        .back-link {
            position: absolute;
            bottom: 10px;
            right: 10px;
        }

        .abutton {
            opacity: 0.75;
            padding: 10px 20px;
            font-size: 16px;
            color: #333;
            background-color: #fff;
            border: 1px solid #ddd;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s, color 0.3s;
        }

        /* 鼠标悬停时的样式 */
        .abutton:hover {
            background-color: #e9e9e9;
            color: #000;
        }

        .abutton:active {
            background-color: #d4d4d4;
            color: #000;
        }

        .login-button {
            padding: 12px 25px;
            font-size: 16px;
            color: #ffffff;
            background: linear-gradient(145deg, #6c63ff, #9c27b0);
            border: none;
            border-radius: 24px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
            cursor: pointer;
            transition: all 0.3s ease;
            outline: none;
        }

        .login-button:hover {
            background: linear-gradient(145deg, #6c63ff, #8e2de2);
            transform: translateY(-2px);
        }

        .login-button:active {
            background: linear-gradient(145deg, #5e50ce, #7b1fa2);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
            transform: translateY(0);
        }

        .login-button:focus {
            outline: none;
            box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.5);
        }
    </style>
</head>

<body>
    <div class="login-box" id="app">
        <form @submit.prevent="login">
            <h2>管理员登录</h2>
            <div class="input-group">
                <label for="musername">用户名:</label>
                <input type="text" v-model="musername" id="musername" required>
            </div>
            <div class="input-group">
                <label for="mpassword">密码:</label>
                <input type="password" v-model="mpassword" id="mpassword" required>
            </div>
            <div class="input-group">
                <button type="submit" class="login-button">登录</button>
            </div>
            <br>
            <br>
            <div class="back-link">
                <button type="button" class="abutton" onclick="window.location.href='/登录注册/用户登录.html';">返回用户端</button>
            </div>
        </form>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                musername: '',
                mpassword: ''
            },
            methods: {
                login() {
                    let data = new FormData();
                    data.append("mname", this.musername);
                    data.append("mpassword", this.mpassword);

                    // 发送 POST 请求进行登录  
                    axios.post("http://localhost:8080/hqdx/manager/login", data)
                        .then(response => {
                            
                            // 判断服务器返回的结果  
                            if (response.data.success) {
                                // 登录成功，直接跳转到目标页面  
                                window.location.href = '管理员-用户信息.html'; // 这里替换为您想要跳转的页面  
                            } else {
                                // 登录失败，提示错误  
                                alert('用户名或密码错误');
                            }
                        })
                        .catch(error => {
                            // 捕捉并打印错误  
                            console.error('请求错误:', error);
                            alert('登录过程中出现问题，请重试。');
                        });
                }
            }
        });
    </script>
</body>

</html>